package main.listeners;

import java.util.ArrayList;
import java.util.List;

public class ListenerClearer {
	
	protected ListenerContainer listenerContainer;
	protected List<Object> listeners;
	
	public ListenerClearer(ListenerContainer listenerContainer) {
		this.listenerContainer = listenerContainer;
		listeners = new ArrayList<Object>();
	}
	
	public void addListener(Object l) {
		listenerContainer.addListener(l);
		listeners.add(l);
	}
	
	public void clear() {
		for(Object l : listeners) {
			listenerContainer.removeListener(l);
		}
		
		listeners.clear();
	}
	
	public ListenerContainer getContainer() { return listenerContainer; }
}